function board(status) {
	var o = "";
	var x = 0;
	var y = 0;
	for(y=0;y<8;y++) {
		for(x=0;x<8;x++) {
			o += piece(JC.GETINFO(status,JC.P(x,y)));
		}
		o += "\n";
	}
	return o;
}

function piece(info) {
	if (false) {
		} else if(info == JC.WHITEPAWN) {return "P";
		} else if(info == JC.WHITEKNIGHT) {return "N";
		} else if(info == JC.WHITEBISHOP) {return "B";
		} else if(info == JC.WHITEROOK) {return "R";
		} else if(info == JC.WHITEQUEEN) {return "Q";
		} else if(info == JC.WHITEKING) {return "K";
		} else if(info == JC.BLACKPAWN) {return "p";
		} else if(info == JC.BLACKKNIGHT) {return "n";
		} else if(info == JC.BLACKBISHOP) {return "b";
		} else if(info == JC.BLACKROOK) {return "r";
		} else if(info == JC.BLACKQUEEN) {return "q";
		} else if(info == JC.BLACKKING) {return "k";
	}
	return ".";
}

function coord(offset) {
	y = div(offset,12)-2;
	x = (offset % 12)-2;
	return String.fromCharCode(97+x)+String.fromCharCode(56-y);
}

function div(n,d) {
    var r = n % d;
    var q = ( n - r ) / d;
    return q;
}

function bin(d) {
	function z(n) {var o="";for(var i=0;i<n;i++)o+="0";return o;}
	d = parseInt(d);
	b = d.toString(2);
	return z(8-b.length)+b;
}

function echo(s) {
	document.write(s);
}
function echon(s) {
	document.write(s+"\n");
}
